package com.epcs.controller.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;

import com.epcs.model.bo.EventBO;
import com.epcs.model.bo.FollowingBO;
import com.epcs.model.bo.UserBO;
import com.epcs.model.dto.Account;
import com.epcs.model.dto.Event;
import com.opensymphony.xwork2.Action;

public class CancelEventJsonAction implements SessionAware{
	private String id;
	private String ajaxResult;
	private SessionMap<String, Object> sessionMap;
	
	// Cancel Event
		public String cancelEvent() {

			Account account = (Account) sessionMap.get("USER_INFO");
			// kiem tra xem co login chua, neu khac null la login roi
			if (account != null) {
				EventBO newEventBO = new EventBO();
				Event event = newEventBO.getEvent(id);
				boolean result = newEventBO.cancelEvent(event);

				if (result){
					ajaxResult = "Success";
				} else {
					ajaxResult = "Fail";
				}
				
			} else {
				ajaxResult = "Unauthorized";
			}
			
			return Action.SUCCESS;

		}

	// ---------------- session --------------------//
	@Override
	public void setSession(Map<String, Object> sessionMap) {
		this.sessionMap = (SessionMap<String, Object>) sessionMap;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getAjaxResult() {
		return ajaxResult;
	}

	public void setAjaxResult(String ajaxResult) {
		this.ajaxResult = ajaxResult;
	}
	
}
